package cn.wolfcode.crm.domain;

import com.alibaba.fastjson.JSON;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 客户跟进历史
 */
@Data
public class CustomerTraceHistory {

    public static final int TYPE_COMMON = 0;//潜客客户跟进
    public static final int TYPE_NORMAL = 1;//正式客户跟进

    private Long id;
    //跟进时间
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date traceTime;
    //跟进记录
    private String traceDetails;
    //交流方式
    private SystemDictionaryItem traceType;
    //跟进结果
    private Integer traceResult;
    //备注
    private String remark;
    //跟进客户
    private Customer customer;
    //录入人
    private Employee inputUser;
    //录入时间
    private Date inputTime;
    //跟进类型
    private Integer type;

    public String getJson(){
        Map map = new HashMap();
        map.put("id",id);
        map.put("traceTime",traceTime);
        map.put("traceDetails",traceDetails);
        map.put("traceType",traceType);
        map.put("traceResult",traceResult);
        map.put("remark",remark);
        map.put("customer",customer);
        map.put("inputUser",inputUser);
        map.put("inputTime",inputTime);
        map.put("type",type);

        return JSON.toJSONString(map);
    }

    public String getTraceResultName(){
        String temp="";
        switch (traceResult){
            case 1: temp="差";break;
            case 2: temp="中";break;
            case 3: temp="优";break;
        }
        return temp;
    }

    public String getTypeName(){
        String temp = "潜在客户";
        switch (type){
            case TYPE_NORMAL:
                temp="正式客户";break;
        }
        return temp;
    }

}